
import { SpriteFrameComponent } from "../../engine/SpriteFrameComponent";
import UIManager from "../../engine/UIManager";
import ViewBase from "../../engine/ViewBase";
import { GameConfig } from "../config/GameConfig";
import { ViewConfig } from "../config/ViewConfig";
import { UIHelper } from "../util/UIHelper";

const { ccclass, property } = cc._decorator;

@ccclass
export default class ViewCoinGame extends ViewBase {

    private gameType: number;

    private renshuConfig: Array<Array<number>> = [
        [2, 3, 4],  //黄骅麻将
   
    ]
    private rangpai:number = 0;   //0:让牌玩法 1:不让牌玩法

    public onInitChild(gameType: number): void {
        this.gameType = gameType;

        let btnBack: cc.Node = this.findChild(this.node, "btnBack")
        UIHelper.onAddEvent(btnBack, () => {
            UIManager.instance.showView(ViewConfig.viewConfig.ViewHall, () => {
                this.closeView()
            })
        })


        this.refresh()
    }


    private refresh() {
       
        for (let i = 0; i < 1; i++) {
            let gameNode: cc.Node = this.findChild(this.node, "gameNode" + i)
            if (i + 1 == this.gameType) {
                gameNode.active = true
                for (let j = 0; j < gameNode.childrenCount; j++) {
                    UIHelper.onAddEvent(gameNode.children[j], () => {
                        this.closeView()
                        let renshu: number = this.renshuConfig[i][j]
                       
                        UIManager.instance.showView(ViewConfig.viewConfig.ViewCoinRoom, null, this.gameType, renshu, this.rangpai)
                    })
                }
            } else {
                gameNode.active = false
            }
        }

    }

}
